package com.mx102.kosmos;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL11;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g3d.loaders.obj.ObjLoader;

public class Bullet {

	private Mesh bullet;
	private float position;
	
	private float x,y,z;
	private Texture texture;
	
	public Bullet(float position) {
		bullet= ObjLoader.loadObj(Gdx.files.internal("rocket.obj").read(),true);
		bullet.scale(2f, 2f, 2f);
		
		texture = new Texture(Gdx.files.internal("rocket.png"), true);
		texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
	
		x=position;
		y=-20;
		
	}
	
	public void render(GL11 gl,float delta) {
		
		
		y+=-150*delta;
		
		gl.glPushMatrix();
		
		gl.glTranslatef(x,z,y);
		gl.glRotatef(90, 0, 1, 0);
		texture.bind();
		bullet.render(GL11.GL_TRIANGLES);
		gl.glPopMatrix();
		
	}
	
	public boolean toDestroy() {
		if (y<-300) return true;
		else return false;
	}
}
